package cn.itlaobing.management.controller.sys;

import cn.itlaobing.management.common.ResponseInfo;
import cn.itlaobing.management.entity.User;
import cn.itlaobing.management.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 马浩 1085473391@qq.com
 * @Package cn.itlaobing.management.controller.sys
 * @Description: TODO (  )
 * @Date 2019/4/8 14:50
 * @Version V1.0
 */
@RestController
public class LoginController {

    @Autowired
    private UserService userService;

    @GetMapping({"","/","/login"})
    public ModelAndView login(){
        ModelAndView mv = new ModelAndView("login");
        return mv;
    }

    @PostMapping("/login")
    public ResponseInfo doLogin(User user, HttpServletRequest request){
        return userService.doLogin(user);
    }

    @GetMapping("/index")
    public ModelAndView index(){
        ModelAndView mv = new ModelAndView("index");
        return mv;
    }
    @GetMapping("/welcome")
    public ModelAndView welcome(){
        ModelAndView mv = new ModelAndView("welcome");
        return mv;
    }

}
